package com.example.mydesignmodule.combination;

/**
 * @author tgw
 * @date 2021/3/10
 * @describe  组合模式  在Android中的应用 例如  view 与 viewgroup
 */
class CombinRunMain {

    public static void main(String[] args) {
        Common root = new Root("root");
        Common leaf = new Leaf("root-leaf.folder");
        Common leaffolder  = new Leaf("leaf-leaf1.folder");
        leaf.addCommon(leaffolder);
        root.addCommon(leaf);
        root.addCommon(new Leaf("root-leaf.txt"));
        leaf.addCommon(new Leaf("leaf-leaf2.txt"));
        leaffolder.addCommon(new Leaf("root-leaf-folder.txt"));
        root.doSomeThing();
        System.out.println("移除一个节点：");
        leaf.removeCommon(leaffolder);
        root.doSomeThing();
        System.out.println("总节点:"+root.toString());
    }
}
